home *** CD-ROM | disk | FTP | other *** search
- /* ***** BEGIN LICENSE BLOCK *****
- *
- * Pearltrees add-on AMO, Copyright(C), 2009, Broceliand SAS, Paris, France
- * (company in charge of developing Pearltrees)
- *
- * This file is part of ΓÇ£Pearltrees add-on AMOΓÇ¥.
- *
- * Pearltrees add-on AMO is free software: you can redistribute it and/or modify it under the
- * terms of the GNU General Public License version 3 as published by the Free Software Foundation.
- *
- * Pearltrees add-on AMO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with Pearltrees add-on AMO.
- * If not, see <http://www.gnu.org/licenses/>
- *
- * ***** END LICENSE BLOCK ***** */
-
- /////////////////////////////////////////////////////////////////////////////////
- // Option window actions
- //
- // Classes:
- //
- // BRO_options
- //
- /////////////////////////////////////////////////////////////////////////////////
-
- /////////////////////////////////////////////////////////////////////////////////
- // Buttons
- /////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Save settings
- * @param event
- */
- function BRO_onAcceptOptions(event) {
- }
- function BRO_onClickCustomize(event) {
- var browserWindow = BRO_options.getBrowserWindow();
- browserWindow.document.getElementById("cmd_CustomizeToolbars").doCommand();
- }
-
- /**
- * Load values
- * @param event
- */
- function BRO_onLoad(event) {
- // Mac hack
- document.documentElement.getButton("accept").hidden = false;
- document.documentElement.getButton("accept").disabled = false;
- document.documentElement.getButton("cancel").hidden = false;
- document.documentElement.getButton("cancel").disabled = false;
-
- // Set server URL
- var serverDescription = document.getElementById('BRO_serverDescription');
- serverDescription.value = BRO_PUBLIC_URL;
-
- // Set source
- var sourceDescription = document.getElementById('BRO_sourceDescription');
- if(BRO_ADDON_SOURCE == BRO_ADDON_SOURCE_AMO) {
- sourceDescription.value = "AMO";
- }
- else {
- sourceDescription.value = "self hosted";
- }
-
- // Set version
- var gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"]
- .getService(Components.interfaces.nsIExtensionManager);
- var currentVersion = gExtensionManager.getItemForID(BRO_ADDON_ID).version;
- var versionDescription = document.getElementById('BRO_versionDescription');
- versionDescription.value = currentVersion;
-
- // Fetch status
- document.getElementById('BRO_statusDescription').value = '...';
- BRO_getStatus();
-
- var prefWindow = document.getElementById("BRO_prefs");
- prefWindow.setAttribute('style','width:auto');
- prefWindow.setAttribute('style','height:auto');
- }
-
- function BRO_getStatus() {
- BRO_model.getTreesAndCurrentUser(skipNotificationIfNotLogged = true);
- }
-
- /////////////////////////////////////////////////////////////////////////////////
- // Actions performed when options is opened
- /////////////////////////////////////////////////////////////////////////////////
-
- var BRO_options = {
-
- _mode:'option',
- _browserWindow:null,
-
- getMode: function() {
- return this._mode;
- },
-
- init: function() {
-
- // We share some classes with the toolbar. Specialy model functionalities.
- var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
- .getService(Components.interfaces.nsIWindowMediator);
- this._browserWindow = wm.getMostRecentWindow("navigator:browser");
- BRO_toolbar = this._browserWindow.BRO_toolbar;
- BRO_log = this._browserWindow.BRO_log;
- BRO_model = this._browserWindow.BRO_model;
- BRO_tools = this._browserWindow.BRO_tools;
- BRO_locale = this._browserWindow.BRO_locale;
-
- BRO_onLoad();
- },
-
- showError: function() {
- },
-
- getBrowserWindow: function() {
- return this._browserWindow;
- }
- };
- BRO_options.init();
-